﻿// -----------------------------
// Copyright © Kodi Studios 2011
// -----------------------------

using System.Collections.Generic;
using System.Net;
using System.Text.RegularExpressions;
using System.Resources;
using System.IO;

namespace Kodi.Picturethrill
{
    class EarthScienceImageProvider : IImageProvider
    {
        static string epodUrl = "http://epod.usra.edu";

        List<string> imageUrls = new List<string>();

        public EarthScienceImageProvider()
        {
        }

        public IList<string> ImageUrls
        {
            get
            {
                if (this.imageUrls.Count == 0)
                {
                    // ExampleMatch: <a href="http://epod.usra.edu/.a/6a0105371bb32c970b0153941f96f2970b-pi" style="display: inline;"><img alt="Parallel roads adjusted" class="asset  asset-image at-xid-6a0105371bb32c970b0153941f96f2970b" src="http://epod.usra.edu/.a/6a0105371bb32c970b0153941f96f2970b-750wi" style="width: 720px;" title="Parallel roads adjusted"></a>
                    string imageUrl = HtmlUtilities.GetImageUrl(epodUrl, new Regex(@"\<a .*href\=\""(http\:\/\/epod\.usra\.edu\/\.\w\/[^\""]+)\"""));
                    imageUrls.Add(imageUrl);
                }

                return this.imageUrls;
            }
        }



        //public string ImageLocal
        //{
        //    get
        //    {
        //        //ResourceManager rm = new ResourceManager(
        //        return string.Empty;
        //    }
        //}

        public string Name
        {
            get
            {
                return "EarthScience";
            }
        }

        public string SiteName
        {
            get
            {
                return epodUrl;
            }
        }
    }
}
